<!DOCTYPE html>
<html ng-app="angular-ui-select2-demo">
<head>
	<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" href="bower_components/select2/select2.css">
	<style>
	.container {
		padding-bottom: 4em;
	}

	h2 {
		border-bottom: 1px solid #ddd;
		margin-top: 2em;
	}
	h3 {
		font-size: 16px;
		font-weight: normal;
		margin-top: 0.2em;
	}
	.select2-container {
	}
	label {
		font-size: 16px;
		font-weight: normal;
		display: block;
		color: #333;
	}
	.example.row {
		margin-top: 1em;
	}
	</style>
	<script src="bower_components/jquery/dist/jquery.js"></script>
	<script src="bower_components/select2/select2.js"></script>
	<script src="bower_components/angular/angular.js"></script>
	<script src="bower_components/angular-ui-select2/src/select2.js"></script>
	<script src="app.js"></script>
	<script>
	$(function() {
		var opts=$('#source').html(), opts2='<option></option>'+opts;
		$('select.populate').each(function() { var e=$(this); e.html(e.hasClass('placeholder')?opts2:opts); });
	});
	</script>
</head>
<body>
	<div class="container" ng-controller="MainCtrl">

		<article class="row" id="basics">
			<h2>The Basics</h2>
			<div class="example row">
				<div class="col-md-4 left">
					<label>&lt;select&gt;</label>
					<select style="width:300px" ui-select2 ng-model="basicsValue" id="source">
						<optgroup label="Alaskan/Hawaiian Time Zone">
							<option value="AK">Alaska</option>
							<option value="HI">Hawaii</option>
						</optgroup>
						<optgroup label="Pacific Time Zone">
							<option value="CA">California</option>
							<option value="NV">Nevada</option>
							<option value="OR">Oregon</option>
							<option value="WA">Washington</option>
						</optgroup>
						<optgroup label="Mountain Time Zone">
							<option value="AZ">Arizona</option>
							<option value="CO">Colorado</option>
							<option value="ID">Idaho</option>
							<option value="MT">Montana</option>
							<option value="NE">Nebraska</option>
							<option value="NM">New Mexico</option>
							<option value="ND">North Dakota</option>
							<option value="UT">Utah</option>
							<option value="WY">Wyoming</option>
						</optgroup>
						<optgroup label="Central Time Zone">
							<option value="AL">Alabama</option>
							<option value="AR">Arkansas</option>
							<option value="IL">Illinois</option>
							<option value="IA">Iowa</option>
							<option value="KS">Kansas</option>
							<option value="KY">Kentucky</option>
							<option value="LA">Louisiana</option>
							<option value="MN">Minnesota</option>
							<option value="MS">Mississippi</option>
							<option value="MO">Missouri</option>
							<option value="OK">Oklahoma</option>
							<option value="SD">South Dakota</option>
							<option value="TX">Texas</option>
							<option value="TN">Tennessee</option>
							<option value="WI">Wisconsin</option>
						</optgroup>
						<optgroup label="Eastern Time Zone">
							<option value="CT">Connecticut</option>
							<option value="DE">Delaware</option>
							<option value="FL">Florida</option>
							<option value="GA">Georgia</option>
							<option value="IN">Indiana</option>
							<option value="ME">Maine</option>
							<option value="MD">Maryland</option>
							<option value="MA">Massachusetts</option>
							<option value="MI">Michigan</option>
							<option value="NH">New Hampshire</option>
							<option value="NJ">New Jersey</option>
							<option value="NY">New York</option>
							<option value="NC">North Carolina</option>
							<option value="OH">Ohio</option>
							<option value="PA">Pennsylvania</option>
							<option value="RI">Rhode Island</option>
							<option value="SC">South Carolina</option>
							<option value="VT">Vermont</option>
							<option value="VA">Virginia</option>
							<option value="WV">West Virginia</option>
						</optgroup>
					</select>
				</div>
				<div class="col-md-8 right">
					<h3>Value</h3>
					<pre>{{ basicsValue }}</pre>
				</div>
			</div>
		</article>

		<article class="row" id="multi">
			<h2>Multi-Value</h2>
			<div class="example row">
				<div class="col-md-4 left">
					<label>&lt;select multiple&gt;</label>
					<select style="width:300px" ui-select2 multiple ng-model="multiValue" class="populate"></select>
				</div>
				<div class="col-md-8 right">
					<h3>Value</h3>
					<pre>{{ multiValue }}</pre>
				</div>
			</div>
			<div class="example row">
				<div class="col-md-4 left">
					<label>Pre-defined value</label>
					<input type="hidden" style="width:300px" ui-select2="multi" ng-model="multi2Value"/>
				</div>
				<div class="col-md-8 right">
					<h3>Config</h3>
					<pre><code>{
    multiple: true,
    query: function (query) {
      query.callback({ results: states });
    },
    initSelection: function(element, callback) {
      var val = $(element).select2('val'),
        results = [];
      for (var i=0; i&lt;val.length; i++) {
        results.push(findState(val[i]));
      }
      callback(results);
    }
  }</code></pre>
					<h3>Value</h3>
					<pre>{{ multi2Value }}</pre>
				</div>
			</div>
		</article>

		<article class="row" id="placeholders">
			<h2>Placeholders</h2>
			<div class="example row">
				<div class="col-md-4 left">
					<label>Using data-attribute</label>
					<select style="width:300px" ui-select2 ng-model="placeholdersValue" class="populate placeholder" data-placeholder="Select a State"></select>
				</div>
				<div class="col-md-8 right">
					<h3>Value</h3>
					<pre>{{ placeholdersValue }}</pre>
				</div>
			</div>
			<div class="example row">
				<div class="col-md-4 left">
					<label>Multiple, using config</label>
					<select style="width:300px" ui-select2="placeholders" multiple ng-model="placeholdersMultiValue" class="populate"></select>
				</div>
				<div class="col-md-8 right">
					<h3>Config</h3>
					<pre><code>{{ placeholders }}</code></pre>
					<h3>Value</h3>
					<pre>{{ placeholdersMultiValue }}</pre>
				</div>
			</div>
		</article>

		<article class="row" id="array">
			<h2>Array Data</h2>
			<div class="example row">
				<div class="col-md-4 left">
					<label>Simple</label>
					<input type="hidden" style="width:300px" ui-select2="array" ng-model="arrayValue"/>
				</div>
				<div class="col-md-8 right">
					<h3>Config</h3>
					<pre><code>{{ array }}</code></pre>
					<h3>Value</h3>
					<pre>{{ arrayValue }}</pre>
				</div>
			</div>
			<div class="example row">
				<div class="col-md-4 left">
					<label>Asynchronous</label>
					<input type="hidden" style="width:300px" ui-select2="arrayAsync" ng-model="arrayAsyncValue"/>
				</div>
				<div class="col-md-8 right">
					<h3>Config</h3>
					<pre><code>{
    query: function (query) {
      query.callback({ results: states });
    },
    initSelection: function(element, callback) {
      var val = $(element).select2('val');
      return callback(findState(val));
    }
  }</code></pre>
					<h3>Value</h3>
					<pre>{{ arrayAsyncValue }}</pre>
				</div>
			</div>
		</article>

	</div>
</body>
</html>
